/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-27 10:41:22
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\EventList.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, CommonButton } from '../Common/options'

export const EventList = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const { userUuid } = JSON.parse(window.sessionStorage.getItem('UserInfo'))
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'createTime@desc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '0b25fdfd-1072-4aa6-9e72-a1d309beb871') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'EventList' },
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '执行人员', rules: true },
            {
                dataIndex: 'recipientMobile',
                title: '联系方式',
                valueType: 'input',
                width: 150,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                ...commonTableList.organizationUuid,
                valueEnum: ClientData.organization,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'eventStatus',
                title: '事件状态',
                rules: true,
                valueType: 'select',
                ellipsis: true,
                width: 100,
                valueEnum: BuiltInData.eventStatus,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'planEndDate',
                title: '计划完成',
                valueType: 'Date',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'endDate',
                title: '完成日期',
                valueType: 'Date',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                ...commonTableList.remark,
                title: '任务说明',
                hideInSearch: true,
                width: 240,
            },
            {
                dataIndex: 'evaluate',
                title: '执行情况',
                valueType: 'input',
                ellipsis: true,
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,

            { ...commonTableList.BeginStatDate, title: '计划日期从' },
            { ...commonTableList.EndStatDate, title: '计划日期到' },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        userUuid === record.createUserUuid && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        userUuid === record.recipientUuid && (
                            <CommonButton
                                key="A01"
                                title="执行情况"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    type: 'EventListStatusModel',
                                    smallTitle: '编辑执行情况',
                                    record,
                                    width: 1000,
                                }}
                            />
                        ),
                        userUuid === record.createUserUuid && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
